CC := aarch64-linux-gnu-gcc

INC := ./3rd/usr/local/include \
		./3rd/usr/include \
		./3rd/usr/include/openssl \
		./3rd/usr/include/aarch64-linux-gnu \
		./3rd/usr/include/aarch64-linux-gnu/openssl \
		./3rd/usr/include/aarch64-linux-gnu/curl

CFLAGS += -Wall -Wextra
CFLAGS += -I/home/lynx/code_sources/gateway
CFLAGS += $(foreach item, $(INC),-I$(item))

LIBS_PATH := ./3rd/usr/local/lib \
				./3rd/lib/aarch64-linux-gnu \
				./3rd/usr/lib/aarch64-linux-gnu \

# LDFLAGS += -lpaho-mqtt3c -lcurl -lcrypto
LDFLAGS += $(foreach item, $(LIBS_PATH),-L$(item))

LIBS := -lpaho-mqtt3c -lcurl -lcrypto

#改为你的开发版IP
PEER := lynx@192.168.31.121

SRCS += $(shell find app -type f -name "*.c")
SRCS += $(shell find daemon -type f -name "*.c")
SRCS += $(shell find ota -type f -name "*.c")
SRCS += $(shell find thirdparty -type f -name "*.c")

OBJS = $(SRCS:.c=.o)

TARGET=obj/gateway

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(OBJS) main.o
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)

obj/%.o:SRCS/%.c
	mkdir -p obj
	$(CC) -o $@ -c $< $(CFLAGS)

$(TARGET) :$(OBJ)
	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)

clean:
	$(RM) $(OBJS) main.o $(TARGET)

test_buffer: $(OBJS) test/test_buffer.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^

test_mqtt: $(OBJS) test/test_mqtt.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^

test_message: $(OBJS) test/test_message.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^

test_task: $(OBJS) test/test_task.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^
